<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title></title>
  </head>
  <body>
    <!-- 1. JS表达式都可以作为插值语法 -->
    <div id="app">
      <div>I have a {{ product }}</div>
      <div>{{ product + 's' }}</div>
      <div>{{ isWorking? 'YES': 'NO' }}</div>
      <div>{{ product.toUpperCase() }}</div>
      <div>{{ product.split('').reverse().join('') }}</div>
      <div>{{ getSalePrice() }}</div>
    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

    <script>
      const { createApp, ref } = Vue;

      /*
      模板语法可以分为两种：
      1. 插值语法
      2. 指令语法

      本小节主要学习插值语法
      */
      createApp({
        setup() {
          const product = ref("apple");
          const isWorking = ref(true);
          const getSalePrice = () => {
            // code...
            return 4399.99;
          };
          return {
            product,
            isWorking,
            getSalePrice,
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
